package com.szlanyou.protocol_service;

/**
 * @author 陈章
 * create at 2021/1/19 16:55
 * desc:
 */
public abstract class Singleton<T> {
    public Singleton() {
    }

    private T mInstance;

    /**
     * 创建单例
     * @return
     */
    protected abstract T create();

    public final T get() {
        synchronized (this) {
            if (mInstance == null) {
                mInstance = create();
            }
            return mInstance;
        }
    }
}
